package com.ruoyi.logistics.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.logistics.domain.TLogistics;
import com.ruoyi.logistics.service.ITLogisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物流管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/logistics/logistics")
public class TLogisticsController extends BaseController
{
    @Autowired
    private ITLogisticsService tLogisticsService;

    /**
     * 查询物流管理列表
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLogistics tLogistics)
    {
        startPage();
        List<TLogistics> list = tLogisticsService.selectTLogisticsList(tLogistics);
        return getDataTable(list);
    }

    /**
     * 导出物流管理列表
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:export')")
    @Log(title = "物流管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLogistics tLogistics)
    {
        List<TLogistics> list = tLogisticsService.selectTLogisticsList(tLogistics);
        ExcelUtil<TLogistics> util = new ExcelUtil<TLogistics>(TLogistics.class);
        util.exportExcel(response, list, "物流管理数据");
    }

    /**
     * 获取物流管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:query')")
    @GetMapping(value = "/{logisticsId}")
    public AjaxResult getInfo(@PathVariable("logisticsId") Long logisticsId)
    {
        return success(tLogisticsService.selectTLogisticsByLogisticsId(logisticsId));
    }

    /**
     * 新增物流管理
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:add')")
    @Log(title = "物流管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLogistics tLogistics)
    {
        return toAjax(tLogisticsService.insertTLogistics(tLogistics));
    }

    /**
     * 修改物流管理
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:edit')")
    @Log(title = "物流管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLogistics tLogistics)
    {
        return toAjax(tLogisticsService.updateTLogistics(tLogistics));
    }

    /**
     * 删除物流管理
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:remove')")
    @Log(title = "物流管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logisticsIds}")
    public AjaxResult remove(@PathVariable Long[] logisticsIds)
    {
        return toAjax(tLogisticsService.deleteTLogisticsByLogisticsIds(logisticsIds));
    }
}
